Skip to content

fix(button): add "use client" directive for RSC compatibility#13

Merged
bob-obringer merged 1 commit intomainfrom
fix/button-use-client
Jan 14, 2026
Merged

fix(button): add "use client" directive for RSC compatibility#13
bob-obringer merged 1 commit intomainfrom
fix/button-use-client

Conversation

@bob-obringer
Copy link
Copy Markdown
Collaborator

Summary

  • Added "use client" directive to Button component
  • Button uses @base-ui/react which requires client-side rendering
  • Fixes crash when Button is used in Server Components that call router.refresh()

Problem

When Button was rendered in a React Server Component context (after router.refresh()), it would crash with:

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
Check the render method of `MenuTrigger`.

Solution

Adding "use client" ensures the Button component is always rendered on the client side, preventing the crash.

Test plan

  • Verify Button works normally in client components
  • Verify Button works in Server Components
  • Verify router.refresh() no longer crashes when Button is in the component tree

🤖 Generated with Claude Code

Button uses @base-ui/react which requires client-side rendering. When
Button was used in Server Components that called router.refresh(), it
would crash with "Element type is invalid" error because base-ui
primitives don't work in server context.

Adding "use client" ensures the Button component is always rendered on
the client side, fixing the crash.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Jan 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
ui Ready Ready Preview, Comment Jan 14, 2026 1:59am

@bob-obringer bob-obringer merged commit c1d361f into main Jan 14, 2026
3 checks passed
@bob-obringer bob-obringer deleted the fix/button-use-client branch January 14, 2026 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant